<?php

use App\Admin\Extensions\Form\Category;
use App\Admin\Extensions\Form\CKEditor;
use App\Admin\Extensions\Form\TencentMap;
use App\Helper\Tool;
use Dcat\Admin\Admin;
use Dcat\Admin\Grid;
use Dcat\Admin\Form;

Dcat\Admin\Form::extend('category', Category::class);
Grid::resolving(function (Grid $grid){
    $grid->model()->orderByDesc("id");
    $grid->paginate(10);
    $grid->disableViewButton();
    $grid->showColumnSelector();
    admin_style(<<<CSS
    .label .ie-wrap .ie-display{
        color:white !important;
    }
    .icon-edit-2{
        color: #0a0a0a;
    }
CSS);
});
Form::resolving(function (Form $form) {
    $form->disableViewButton();
    $form->disableViewCheck();
    $form->tools(function (Form\Tools $tools) {
        $tools->disableDelete();
    });
});
admin_css("/static/css/common.css");
admin_script(<<<JS
    layer.config({
      skin: 'layer-skin-primary'
    });
    $(function () {
      $('[data-toggle="tooltip"]').tooltip()
    })
JS);
// 注册前端组件别名
Admin::asset()->alias('@ckeditor', [
    'js' => [
        '/static/packages/ckeditor/ckeditor.js',
        '/static/packages/ckeditor/adapters/jquery.js',
    ],
]);
Admin::asset()->alias('@vue', [
    'js' => [
        "/static/packages/vue/vue.global.prod.js",
        "/build/index.iife.js",
        "/static/packages/common/dayjs.min.js",
    ],
]);
Admin::asset()->alias('@echarts', [
    'js' => ["/static/packages/echarts/echarts.min.js"],
]);
Form::extend('ckeditor', CKEditor::class);
Form::extend('tencent_map', TencentMap::class);
Admin::requireAssets('@vue');
Admin::requireAssets('@echarts');
//$shopUser = auth("shop")->user();
//if ($shopUser){
//    $shop_id = $shopUser->id;
//    Tool::websocket($shop_id);
//}

